package com.yjj.demo.id.generator.web;

import com.yjj.demo.id.generator.service.IIdGeneratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotEmpty;

/**
 *
 *
 * @author yangjiajia
 * @time 2021/6/27 16:48
 */
@RestController
public class IdGeneratorController {

    @Autowired
    @Qualifier("defaultIdGeneratorService")
    private IIdGeneratorService defaultIdGeneratorService;

    @RequestMapping(value = "nextId", method = RequestMethod.GET)
    public long nextId(@NotEmpty @RequestParam("module") String module) {
        return defaultIdGeneratorService.nextId(module);
    }
}
